package com.gjy.sb2.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-11-13 10:02:15
 */
@RestController
@RequestMapping("/hello")
public class HelloController {
    private static final Logger log = LoggerFactory.getLogger(HelloController.class);

    @RequestMapping("/ip")
    public String ip() throws Exception {
        InetAddress localHost = InetAddress.getLocalHost();
        log.info("localHost: {}", localHost);
        return "localhost: " + localHost;
    }

    @RequestMapping("/world")
    public String hello() {
        log.info("/hello/world");
        return "hello world";
    }

    @RequestMapping("/test")
    public String test() {
        log.info("/hello/test");
        return "test";
    }

    @RequestMapping("/h1/{h}")
    public String test1(@PathVariable String h) {
        log.info("/hello/{}", h);
        return h;
    }
}
